package com.brzjomo.secretiveworld.object.item;

import java.util.List;

import com.brzjomo.secretiveworld.util.helper.KeyboardHelper;
//import com.lazy.baubles.api.BaubleType;
//import com.lazy.baubles.api.IBauble;
//import com.lazy.baubles.api.cap.BaublesCapabilities;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Rotation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;

public class SealItem30782 extends Item {

	public SealItem30782(Properties properties) {
		super(properties);
	}

	// 增加物品提示
	@Override
	public void addInformation(ItemStack stack, World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
		if (KeyboardHelper.isHoldingShift()) {
			tooltip.add(new TranslationTextComponent("tooltip.secretiveworld.seal_item_3_0782_1"));
			tooltip.add(new TranslationTextComponent("tooltip.secretiveworld.seal_item_3_0782_2"));
			tooltip.add(new TranslationTextComponent("tooltip.secretiveworld.seal_item_3_0782_3"));
			tooltip.add(new TranslationTextComponent("tooltip.secretiveworld.seal_item_3_0782_4"));
		} else {
			tooltip.add(new TranslationTextComponent("tooltip.secretiveworld.seal_item_3_0782_1"));
			tooltip.add(new TranslationTextComponent("tooltip.secretiveworld.seal_item_3_0782_5"));
		}
		super.addInformation(stack, worldIn, tooltip, flagIn);
	}

	@Override
	public ActionResultType onItemUse(ItemUseContext context) {
		World world = context.getWorld();
		BlockPos blockpos = context.getPos();
		BlockState blockstate = world.getBlockState(blockpos);
		Rotation rot = Rotation.CLOCKWISE_90;
		Block block = blockstate.getBlock();
		if (block != null && KeyboardHelper.isHoldingShift()) {
			PlayerEntity playerentity = context.getPlayer();
			world.playSound(playerentity, blockpos, SoundEvents.BLOCK_ANVIL_LAND, SoundCategory.BLOCKS, 1.0F, 1.0F);
			if (!world.isRemote) {
				if (playerentity != null) {
					world.setBlockState(blockpos, blockstate.rotate(rot), 2);
					playerentity.sendMessage(new TranslationTextComponent("isRotate?", 0));
				}
			}
			return ActionResultType.SUCCESS;
		} else {
			return ActionResultType.PASS;
		}
	}
}
